package com.heatup.apt.management.service.access.impl;

import com.heatup.apt.common.dao.DoorAccessPwdMapper;
import com.heatup.apt.management.service.access.AccessService;
import com.heatup.apt.model.DoorAccessPwd;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Blank on 2016-11-2.
 */
@Service
public class AccessServiceImpl implements AccessService {

    @Autowired
    DoorAccessPwdMapper accessPwdMapper;

    /**
     * 用户门禁密码分页查询
     * @param paramsMap
     * @return
     */
    @Override
    public Map<String, Object> queryAccessPwdList(Map<String, Object> paramsMap) {

        Map<String, Object> resultMap = new HashMap();
        paramsMap.put("pageIndex",(Integer)paramsMap.get("pageIndex") * (Integer)paramsMap.get("pageSize"));
        if ((Integer)paramsMap.get("relationType") == 0) {
            //订单密码
            List<DoorAccessPwd> list = accessPwdMapper.queryOrderAccessPwdList(paramsMap);
            resultMap.put("accessPwdList", list);
            resultMap.put("accessPwdCount", accessPwdMapper.queryOrderAccessPwdCount(paramsMap));
        }
        if ((Integer)paramsMap.get("relationType") == 1) {
            //教练密码
            List<DoorAccessPwd> list = accessPwdMapper.queryCoachAccessPwdList(paramsMap);
            resultMap.put("accessPwdList", list);
            resultMap.put("accessPwdCount", accessPwdMapper.queryCoachAccessPwdCount(paramsMap));
        }
        if ((Integer)paramsMap.get("relationType") == 2) {
            //系统用户密码
            List<DoorAccessPwd> list = accessPwdMapper.querySystemUserAccessPwdList(paramsMap);
            resultMap.put("accessPwdList", list);
            resultMap.put("accessPwdCount", accessPwdMapper.querySystemUserAccessPwdCount(paramsMap));
        }


        return resultMap;
    }

}
